<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Vue学习</title>
    <!-- 引入vue.js -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!--引入vue-resource.js插件-->
    <script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.2"></script>
</head>
<body>
<div id="app">
    用户名：<input type="text" v-model="user"><br>
    密码：<input type="password" v-model="password"><br>
    <input type="button" value="submit" @click="login()">
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            user: 'admin',
            password: 'admin'
        },
        methods: {
            login: function () {
                this.$http.get('http://localhost:8080/studentManagementSystem/login-servlet', {
                    params: {
                        user: this.user,
                        password: this.password
                    }
                }).then(function (data) {
                    if (data.data.ok !== 1) {
                        alert(data.data.msg);
                    } else {
                        alert(data.data.msg);
                    }
                }, function () {
                    console.log('传输失败');
                });
            }
        }
    })
</script>
</body>
</html>